﻿using Entity;
using IRealize;
using Microsoft.AspNetCore.Mvc;
using Realize;

namespace WebApplication9.Controllers.Recruit_Manage.MS
{
    public class EI_SXController : Controller
    {

        private readonly IConfiguration configuration;

        public EI_SXController(IConfiguration configuration)
        {
            this.configuration = configuration;
        }
        public IActionResult Index()
        {
            return View();
        }

        public async Task<IActionResult> Select_EI(int CurrentPage, int PageSize)
        {
            IEI eI = new EI();
            List<Engage_Interview> zhi = await eI.Select_EI(configuration["SqlServer"]);
            List<Engage_Interview> zhi2 = zhi.Skip((CurrentPage - 1) * PageSize).Take(PageSize).ToList();
            PagedViewModel<Engage_Interview> cc = new PagedViewModel<Engage_Interview>() { itemas = zhi2, total = zhi.Count };
            return Ok(new
            {
                list = cc  
            });
        }
        
        public IActionResult Upd(string id)
        {
            ViewBag.TitleId = id;
            return View();
        }

        public async Task<IActionResult> SelectById_EI(string id)
        {
            IEI eI = new EI();
            Engage_Interview ei = await eI.SelectById_EI(id, configuration["SqlServer"]);
            return Ok(new
            {
                zhi = ei
            });
        }

        public async Task<IActionResult> Upd_EIAndRR(string id,string jlid,string zt)
        {
            IER eR = new ER();
            int result = await eR.Tgms(id,jlid,zt, configuration["SqlServer"]);
            if (result > 0)
            {
                return Ok(new
                {
                    zhi = "ok"
                });
            }
            else
            {
                return Ok(new
                {
                    zhi = "nook"
                });
            }
        }

    }
}
